package com.wan37.logic.shop.dao.impl;

import com.wan37.logic.shop.dao.ShopDao;
import com.wan37.logic.shop.domain.entity.ShopDO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate5.HibernateTemplate;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author : luoyong
 * @date : 2020-08-10 18:06
 **/
@Repository
@Transactional(propagation = Propagation.SUPPORTS, rollbackFor = Exception.class)
public class ShopDaoImpl implements ShopDao {
    @Autowired
    private HibernateTemplate hibernateTemplate;
    @Override
    public List<ShopDO> findShopByShopId(String shopId) {
        return (List<ShopDO>) hibernateTemplate.find("from ShopDO where shopId = ?", shopId);
    }

    @Override
    public boolean add(ShopDO shopDO) {
        hibernateTemplate.save(shopDO);
        return true;
    }

    @Override
    public boolean delete(Integer id) {
        return false;
    }

    @Override
    public boolean update(ShopDO shopDO) {
        return false;
    }

    @Override
    public List<ShopDO> getAll() {
        return (List<ShopDO>) hibernateTemplate.find("from ShopDO ");
    }
}
